﻿#pragma once

#include <cstdint>
#include <hadoop/JobConf.h>
namespace HadoopPipes {

	/**
	* Task context provides the information about the task and job.
	*/
	class TaskContext {
	public:
		/**
		* Counter to keep track of a property and its value.
		*/
		class Counter {
		private:
			int id;
		public:
			Counter(int counterId) : id(counterId) {}
			Counter(const Counter& counter) : id(counter.id) {}

			int getId() const { return id; }
		};

		/**
		* Get the JobConf for the current task.
		*/
		virtual const JobConf* getJobConf() = 0;

		/**
		* Get the current key. 
		* @return the current key
		*/
		virtual const std::string& getInputKey() = 0;

		/**
		* Get the current value. 
		* @return the current value
		*/
		virtual const std::string& getInputValue() = 0;

		/**
		* Generate an output record
		*/
		virtual void emitRecord(const std::string& key, const std::string& value) = 0;

		/**
		* Mark your task as having made progress without changing the status 
		* message.
		*/
		virtual void progress() = 0;

		/**
		* Set the status message and call progress.
		*/
		virtual void setStatus(const std::string& status) = 0;

		/**
		* Register a counter with the given group and name.
		*/
		virtual Counter* 
			getCounter(const std::string& group, const std::string& name) = 0;

		/**
		* Increment the value of the counter with the given amount.
		*/
		virtual void incrementCounter(const Counter* counter, uint64_t amount) = 0;

		virtual ~TaskContext() {}
	};
}